/**
 * @author      CPT 236 - 001
 *
 * @version     1.0 Final (maybe)
 */

package battleship.gui;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
* Class that sets up the 'Start Menu' GUI.
*
* Class that sets up the 'Start Menu' that is displayed when the game is 
* first started or after 'New Game' is clicked on the 'Game Over' menu.
*/

public class StartMenu extends JFrame implements ActionListener{
	private JButton start = new JButton("Start Game");
	private JButton exit = new JButton("Exit");
	
   
		/**
		* Method that sets up the 'Start Menu' GUI, inculding a title, and 
		* two buttons, 'Start' and 'Exit'.
		*/   
	public StartMenu(){
		super("Battleship: Start Menu");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(400, 200);
		setVisible(true);
		
		JPanel labelPanel = new JPanel();
		JLabel title = new JLabel(" BATTLESHIP ", JLabel.CENTER);
		
		title.setFont(new Font("Stencil", Font.ITALIC, 48));
		title.setForeground(Color.red);
		labelPanel.add(title);
		add(labelPanel, BorderLayout.NORTH);
		
		JPanel infoPanel = new JPanel();
		JLabel info = new JLabel("Created By CPT 236-001");
		infoPanel.add(info);
		add(infoPanel, BorderLayout.CENTER);
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.add(start);
		buttonPanel.add(exit);
		add(buttonPanel, BorderLayout.SOUTH);
		
		start.addActionListener(this);
		exit.addActionListener(new Exit());
	}
	
   
    /**
		* Method that creates an instance of 'Gameplay', the actual game, and hides the start menu.
		*/
	public void actionPerformed(ActionEvent aE){
		new GamePlay();
		setVisible(false);
		
	}
	
	  /**
		* Listener for 'Exit'.
		*/
	class Exit implements ActionListener {
		public void actionPerformed(ActionEvent aE){
			Exit();
		}
	}
   
	/**
		* Method for 'Exit', which surprisingly enough exits. Who would've guessed?
		*/
	private void Exit(){
		System.exit(0);
	}
}